package com.wl.android.flutterdemo

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import com.wl.android.flutterdemo.databinding.ActivityTestBinding


// Created by wangliang on 2024/4/24.
class TestActivity : AppCompatActivity() {

    private var binding: ActivityTestBinding? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val params = intent?.getSerializableExtra("params") as? Map<String, Any> ?: HashMap()

        Log.d("WLTest", "TestActivity params: $params")

        binding = ActivityTestBinding.inflate(LayoutInflater.from(this)).also {
            setContentView(it.root)
        }
        binding?.appbar?.btnBack?.isVisible = true
        binding?.appbar?.btnBack?.setOnClickListener { finish() }
        binding?.appbar?.titleTv?.text = "Test Page"

        binding?.finishBtn?.setOnClickListener {
            val intent = Intent().apply {
                putExtra("msg", "This is from Native content")
                putExtra("bool", true)
                putExtra("int", 666)
            }
            setResult(Activity.RESULT_OK, intent)
            finish()
        }
    }
}